<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Str;


class ImageController extends Controller
{
    //上传图片文件单张
    public function upload(Request $request){

      //  dd( $request->allFiles());

        $file=$request->file('file');
        $filename=Str::random(20);
        $path='image'.'/'.date('F').date('Y').'/';
        $fullPath='/storage/'.$path.$filename.'.'.$file->getClientOriginalExtension();
        $file->storeAs('public/'.$path,$filename.'.'.$file->getClientOriginalExtension());
        return [
            "code"=>0,
            'msg'=>trans('message.upload_success'),
            "data"=>[
                'src'=>$fullPath
            ]
        ];

    }
    //上传图片文件单张
    public function upload1(Request $request){

        //  dd( $request->allFiles());

        $file=$request->file('file');
        $filename=Str::random(20);
        $path='image'.'/'.date('F').date('Y').'/';
        $fullPath='/storage/'.$path.$filename.'.'.$file->getClientOriginalExtension();
        $file->storeAs('public/'.$path,$filename.'.'.$file->getClientOriginalExtension());
        return [
            "code"=>0,
            'msg'=>trans('message.upload_success'),
            "data"=>[
                'src'=>$fullPath
            ]
        ];

    }
}
